package com.yang.controller;

import java.util.HashSet;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yang.entity.Permissions;
import com.yang.entity.Roles;
import com.yang.model.Page;
import com.yang.service.PermissionService;
import com.yang.service.RoleService;
/**
 * 描述：角色相关的控制器
 * 版本：1.0
 * 作者： 杨建全
 * 创建时间：2016年3月24日  下午3:57:37
 */
@Controller
@RequestMapping("/role")
public class RoleController {
	
	@Autowired
	private RoleService roleService;
	@Autowired
	private PermissionService permissionService;
	
	@RequestMapping("/roleList")
	public String getView(String nowPage,HttpServletRequest request){
		Page<Roles> page = roleService.getRolePage(nowPage, "10");
		request.setAttribute("page", page);
		return "/role/list";
	}
	
	@RequiresAuthentication
	@RequestMapping("/editRoleView")
	public String editRoleView(String id,HttpServletRequest request){
		Roles role =  roleService.findOne(id);
		request.setAttribute("role", role);
		return "/role/editModal";
	}
	
	@ResponseBody
	@RequiresAuthentication
	@RequestMapping("/editRoleSubmit")
	public String editRoleSubmit(Roles role){
		roleService.updateRole(role);
		return "";
	}
}
